import {Injectable} from 'angular2/core';
import {VARIABLE} from '../utils/variable';
import {PostService} from './post';
import {Product} from '../models/product';

@Injectable()
export class SearchService {
    constructor(private _postService: PostService) { }
    
    _apiSearch = '/search/search';
    _apiHistory = '/search/getHistory';
    _apiKeywords = '/search/getMatchedKeywords';

    search(keywords) {
        return this._postService.post(this._apiSearch, {keywords: keywords, category: VARIABLE.CURRENT_CATEGORY});
    }

    getHistory() {
        return this._postService.post(this._apiHistory, {});
    }
    
    getMatchedKeywords(keywords) {
        return this._postService.post(this._apiKeywords, {keywords: keywords, category: VARIABLE.CURRENT_CATEGORY});
    }
}
